Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PERF] remove pointee types from cg_ssa and cg_llvm #105412

Closed
wants to merge 4 commits into from

Conversation

erikdesjardins
Copy link
Contributor

@erikdesjardins erikdesjardins commented Dec 7, 2022

Modern LLVM (15+ by default) doesn't have pointee types, so computing them is a waste of time.

This can't be merged in its current state, because:

  • current LLVM 15 allows -Cllvm-args="-opaque-pointers=0" (not sure that we should support this configuration though)
  • we support older LLVM versions without fully working opaque pointers

Workarounds could be:

  • cx.type_ptr_to(|| ...compute pointee type...), closure only called in LLVM < 15 (kinda awkward)
  • targeted if llvm_version < 15 { cx.type_ptr_to(...compute pointee type...) } else { cx.type_i8p() } only at important callsites (might have to end up doing this)

This is just to measure the max possible perf win from everything.

r? @ghost

@rustbot label S-experimental

i expected to need to add casts to load/store/memcpy/memmove/memset/etc.
but they already pointercast their arguments, so with the (relatively
minimal) number of pointer types created in cg_ssa, this should work?
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels Dec 7, 2022
@erikdesjardins
Copy link
Contributor Author

(LLVM 13 failure is expected, since this uses opaque pointer apis)

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling rustc_driver v0.0.0 (/checkout/compiler/rustc_driver)
   Compiling rustc_smir v0.0.0 (/checkout/compiler/rustc_smir)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcojFrSa/symbols.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-602df7e84a3bff2a.rustc_main.0adb0a0e-cgu.0.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-602df7e84a3bff2a.rustc_main.0adb0a0e-cgu.1.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-602df7e84a3bff2a.rustc_main.0adb0a0e-cgu.2.rcgu.o" "-Wl,--as-needed" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/psm-2d62ee42e328dbec/out" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/rustc_llvm-630d40fd1b46c1ad/out" "-L" "/usr/lib/llvm-13/lib" "-L" "/usr/lib/gcc/x86_64-linux-gnu/11" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps" "-lrustc_driver-a0f2c73fcc922bb4" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-e30d9af640d9254d" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-e3d6f129733638bb.rlib" "-Wl,-Bdynamic" "-lLLVM-13" "-ldl" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_main-602df7e84a3bff2a" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /usr/bin/ld: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_driver-a0f2c73fcc922bb4.so: undefined reference to `LLVMPointerTypeInContext'
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
error: could not compile `rustc-main` due to previous error
Build completed unsuccessfully in 0:03:34

@Dylan-DPC
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 7, 2022
@bors
Copy link
Contributor

bors commented Dec 7, 2022

⌛ Trying commit 68cabc0 with merge 04e8510cb4b06cc25af99d5841acc4a2b9e3a4ca...

@bors
Copy link
Contributor

bors commented Dec 7, 2022

☀️ Try build successful - checks-actions
Build commit: 04e8510cb4b06cc25af99d5841acc4a2b9e3a4ca (04e8510cb4b06cc25af99d5841acc4a2b9e3a4ca)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (04e8510cb4b06cc25af99d5841acc4a2b9e3a4ca): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.8% [1.8%, 1.8%] 1
Improvements ✅
(primary)
-0.8% [-1.4%, -0.2%] 4
Improvements ✅
(secondary)
-0.9% [-0.9%, -0.9%] 1
All ❌✅ (primary) -0.8% [-1.4%, -0.2%] 4

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.3% [-3.3%, -3.3%] 1
Improvements ✅
(secondary)
-0.7% [-1.3%, -0.5%] 3
All ❌✅ (primary) -3.3% [-3.3%, -3.3%] 1

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.2% [-1.4%, -1.1%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.2% [-1.4%, -1.1%] 2

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 7, 2022
@erikdesjardins
Copy link
Contributor Author

Wow, this doesn't help at all! Interesting...

I didn't expect the pointercast removal to improve anything (since LLVM will either avoid generating bitcast ptr to ptr or immediately optimize it out), but I hoped 0fcc9be (#105412) (which depends on the other changes) would be a small win across the board, like #94107.

I guess I'll invert this change, leave pointer types in cg_ssa, and only keep the cg_llvm changes as a future cleanup.

@erikdesjardins erikdesjardins deleted the opaque branch December 11, 2022 00:50
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2023
cleanup: remove pointee types

This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after rust-lang#114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.)

I initially hoped this would provide some minor perf win, but in rust-lang#105412 (comment) it had very little impact, so this is only valuable as a cleanup.

As a followup, this will enable rust-lang#96242 to be resolved.

r? `@ghost`

`@rustbot` label S-blocked
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 2, 2023
cleanup: remove pointee types

This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.)

I initially hoped this would provide some minor perf win, but in rust-lang/rust#105412 (comment) it had very little impact, so this is only valuable as a cleanup.

As a followup, this will enable #96242 to be resolved.

r? `@ghost`

`@rustbot` label S-blocked
antoyo pushed a commit to rust-lang/rustc_codegen_gcc that referenced this pull request Aug 13, 2023
cleanup: remove pointee types

This can't be merged until the oldest LLVM version we support uses opaque pointers, which will be the case after #114148. (Also note `-Cllvm-args="-opaque-pointers=0"` can technically be used in LLVM 15, though I don't think we should support that configuration.)

I initially hoped this would provide some minor perf win, but in rust-lang/rust#105412 (comment) it had very little impact, so this is only valuable as a cleanup.

As a followup, this will enable #96242 to be resolved.

r? `@ghost`

`@rustbot` label S-blocked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants